

const modules = import.meta.globEager('./components/*.jsx')

let componentMap = {}
for (const path in modules) {
  // 
  /**
   * 加载component文件下的所有表单类型组件
   */

  let fileName = path.split('/').pop().replace('.jsx', '')
  componentMap[fileName] = modules[path].default
}

/**
 * 
 * @param { object } props.column 列数据，必填
 * @param { object } props.initialValues 表单要更新的值，选填
 * @param { Array } props.disabledColumnNames 强制disable禁止操作，选填
 * @returns 
 */
function YyFormItem({ form, column, showLabel = true, initialValues = {}, disabledColumnNames = [], selectAllowClear = false }) {
  let Component = componentMap[column.form_type]

  return (
    <Component
      form={form}
      column={column}
      showLabel={showLabel}
      selectAllowClear={selectAllowClear}
      initialValues={initialValues}
      disabledColumnNames={disabledColumnNames}
    ></Component>
  )
}

export default YyFormItem